package com.ccb.cloud.rca.appservice.service.reform.impl;

import com.ccb.cloud.rca.appservice.dao.DO.reform.CgCheckBalanceSheet192DO;
import com.ccb.cloud.rca.appservice.dao.mapper.reform.CgCheckBalanceSheet192Mapper;
import com.ccb.cloud.rca.appservice.dto.ReqPaginationBase;
import com.ccb.cloud.rca.appservice.dto.reform.CgCheckBalanceSheet192DTO;
import com.ccb.cloud.rca.appservice.vo.reform.CgCheckBalanceSheet192VO;
import com.ccb.cloud.rca.appservice.service.reform.ICgCheckBalanceSheet192Service;
import com.ccb.cloud.rca.appservice.util.StrUtils;
import com.ccb.cloud.rca.appservice.model.RcaServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
/**
 * @author yonggang.wang
 * @Description CgCheckBalanceSheet192ServiceImpl
 * @create 2021-11-29
 */
@Service
public class CgCheckBalanceSheet192ServiceImpl implements ICgCheckBalanceSheet192Service {

    private final static Logger LOGGER = LoggerFactory.getLogger(CgCheckBalanceSheet192ServiceImpl.class);

    @Autowired
    private CgCheckBalanceSheet192Mapper cgCheckBalanceSheet192Mapper;

    /**
     * 查询列表
     * @param cgCheckBalanceSheet192dto
     * @return
     */
    @Override
    public List<CgCheckBalanceSheet192VO> queryList(CgCheckBalanceSheet192DTO cgCheckBalanceSheet192dto) {
        CgCheckBalanceSheet192DO cgCheckBalanceSheet192do = new CgCheckBalanceSheet192DO();
        if(null != cgCheckBalanceSheet192dto) BeanUtils.copyProperties(cgCheckBalanceSheet192dto,cgCheckBalanceSheet192do);
        List<CgCheckBalanceSheet192VO> list = cgCheckBalanceSheet192Mapper.queryList(cgCheckBalanceSheet192do);
        LOGGER.info("查询列表res=>{}",list);
        return list;
    }

    /**
     * 添加对象
     * @param cgCheckBalanceSheet192dto
     */
    @Override
    public void addObject(CgCheckBalanceSheet192DTO cgCheckBalanceSheet192dto) {
        CgCheckBalanceSheet192DO cgCheckBalanceSheet192do = new CgCheckBalanceSheet192DO();
        if(null != cgCheckBalanceSheet192dto) BeanUtils.copyProperties(cgCheckBalanceSheet192dto,cgCheckBalanceSheet192do);
        cgCheckBalanceSheet192Mapper.insert(cgCheckBalanceSheet192do);
    }

    /**
     * 修改对象
     * @param cgCheckBalanceSheet192dto
     */
    @Override
    public void updateObject(CgCheckBalanceSheet192DTO cgCheckBalanceSheet192dto) {
        CgCheckBalanceSheet192DO cgCheckBalanceSheet192do = new CgCheckBalanceSheet192DO();
        if(null != cgCheckBalanceSheet192dto) BeanUtils.copyProperties(cgCheckBalanceSheet192dto,cgCheckBalanceSheet192do);
        //=== mod by wang  2021-11-29=更新表中需含主键==
        if(!StrUtils.isNotBlank(cgCheckBalanceSheet192do.getId())) throw new RcaServiceException("修改缺少主键");
        cgCheckBalanceSheet192Mapper.update(cgCheckBalanceSheet192do);
    }

    /**
     * 删除对象
     * @param cgCheckBalanceSheet192dto
     */
    @Override
    public void deleteObject(CgCheckBalanceSheet192DTO cgCheckBalanceSheet192dto) {
        CgCheckBalanceSheet192DO cgCheckBalanceSheet192do = new CgCheckBalanceSheet192DO();
        if(null != cgCheckBalanceSheet192dto) BeanUtils.copyProperties(cgCheckBalanceSheet192dto,cgCheckBalanceSheet192do);
        //=== mod by wang  2021-11-29=删除表需要有主键==
        if(!StrUtils.isNotBlank(cgCheckBalanceSheet192do.getId())) throw new RcaServiceException("删除缺少主键");
        cgCheckBalanceSheet192Mapper.delete(cgCheckBalanceSheet192do);
    }

    /**
     * 查询一条
     * @param cgCheckBalanceSheet192dto
     * @return
     */
    @Override
    public CgCheckBalanceSheet192VO queryDetail(CgCheckBalanceSheet192DTO cgCheckBalanceSheet192dto) {
        CgCheckBalanceSheet192DO cgCheckBalanceSheet192do = new CgCheckBalanceSheet192DO();
        if(null != cgCheckBalanceSheet192dto) BeanUtils.copyProperties(cgCheckBalanceSheet192dto,cgCheckBalanceSheet192do);
        CgCheckBalanceSheet192VO one = cgCheckBalanceSheet192Mapper.queryDetail(cgCheckBalanceSheet192do);
        LOGGER.info("查询一条res=>{}",one);
        return one;
    }

    /**
     * 分页查询
     * @param cgCheckBalanceSheet192ReqPagination
     * @return
     */
    @Override
    public PageInfo<CgCheckBalanceSheet192VO> queryPage(ReqPaginationBase<CgCheckBalanceSheet192DTO> cgCheckBalanceSheet192ReqPagination) {
        CgCheckBalanceSheet192DTO data = cgCheckBalanceSheet192ReqPagination.getData();
        PageHelper.startPage(cgCheckBalanceSheet192ReqPagination.getPageNum(), cgCheckBalanceSheet192ReqPagination.getPageSize());
        PageInfo<CgCheckBalanceSheet192VO> cgCheckBalanceSheet192PageInfo = new PageInfo<CgCheckBalanceSheet192VO>(this.queryList(data));
        LOGGER.info("分页查询res=>{}",cgCheckBalanceSheet192PageInfo);
        return cgCheckBalanceSheet192PageInfo;
    }
    /**
     * 批量新增或修改
     * @param list
     */
    @Override
    @Transactional
    public void insertBatch(List<CgCheckBalanceSheet192DO> list) {
        cgCheckBalanceSheet192Mapper.insertBatch(list);
    }

    /**
     * 批量删除
     * @param list
     */
    @Override
    @Transactional
    public void deleteBatch(List<CgCheckBalanceSheet192DO> list) {
        cgCheckBalanceSheet192Mapper.deleteBatch(list);
    }
}
